/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "cargo_respon", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CargoRespon.findAll", query = "SELECT c FROM CargoRespon c"),
    @NamedQuery(name = "CargoRespon.findByIdCargoRespon", query = "SELECT c FROM CargoRespon c WHERE c.idCargoRespon = :idCargoRespon"),
    @NamedQuery(name = "CargoRespon.findByNombre", query = "SELECT c FROM CargoRespon c WHERE c.nombre = :nombre")})
public class CargoRespon implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_cargo_respon", nullable = false)
    private Integer idCargoRespon;
    @Size(max = 45)
    @Column(name = "nombre", length = 45)
    private String nombre;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cargoRespon", fetch = FetchType.LAZY)
    private List<MovEncarga> movEncargaList;

    public CargoRespon() {
    }

    public CargoRespon(Integer idCargoRespon) {
        this.idCargoRespon = idCargoRespon;
    }

    public Integer getIdCargoRespon() {
        return idCargoRespon;
    }

    public void setIdCargoRespon(Integer idCargoRespon) {
        this.idCargoRespon = idCargoRespon;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    @XmlTransient
    public List<MovEncarga> getMovEncargaList() {
        return movEncargaList;
    }

    public void setMovEncargaList(List<MovEncarga> movEncargaList) {
        this.movEncargaList = movEncargaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCargoRespon != null ? idCargoRespon.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CargoRespon)) {
            return false;
        }
        CargoRespon other = (CargoRespon) object;
        if ((this.idCargoRespon == null && other.idCargoRespon != null) || (this.idCargoRespon != null && !this.idCargoRespon.equals(other.idCargoRespon))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
     //   return "Entidades.CargoRespon[ idCargoRespon=" + idCargoRespon + " ]";
          return idCargoRespon + "  "+" - " +nombre.trim();
    }
}
